home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / misc / football / user / viewteamschedule.rexx < prev   
OS/2 REXX Batch file  |  1999-02-03  |  5KB  |  169 lines

  1. /* ***********************************************************************
  2.  
  3.    VIEW TEAM SCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       150997   First release.
  11.            151297   Tidied display.
  12.  
  13. **************************************************************************
  14.  
  15. Procedure
  16. ---------
  17.  
  18. 1. Check files exist. Read Teams.df datafile and store teams.
  19. 2. If league has not been autoscheduled then give an error and quit.
  20. 3. Search for specified team and if not found, give an error and quit.
  21. 4. Open Teams.sf datafile.
  22. 5. If "Week" or "Date" is found, grab the data and format it for later.
  23. 6. Use selected team against either HOME or AWAY team and if a match that
  24.    has yet to be played is found, display the data.
  25. 7. When the file is finished, print the number of matches and exit...
  26.  
  27. ************************************************************************** */
  28. PARSE ARG league_stuff
  29.  
  30. version      = 1
  31. input_file   = '.df'
  32. input2_file  = '.sf'
  33. title        = '*LEAGUE_NAME='
  34. autosched    = '*AUTOSCHD='
  35. separator    = '*'
  36. teams.       = '???'
  37. counter      = 0
  38. not_played   = '__   __'
  39.  
  40.  
  41. parse var league_stuff league_file search_team
  42. league_file = "Data/" || league_file
  43.  
  44. if exists(league_file || input_file) = 0  then exit
  45. if exists(league_file || input2_file) = 0 then exit
  46.  
  47. autos = 0
  48. if open(datafile,league_file || input_file,'r') then do
  49.    do while ~eof(datafile)
  50.       line = readln(datafile)
  51.       if pos(title,line) > 0 then
  52.          league_title = delstr(line,1,13)
  53.       if pos(autosched,line) > 0 then do
  54.          autofile = delstr(line,1,10)
  55.          autos = 1
  56.       end
  57.       if pos(separator,line) = 0 then do
  58.          line = strip(line)
  59.          if counter = 0 then do
  60.             teams.1 = line
  61.             counter = 1
  62.          end
  63.          else do
  64.             counter       = counter + 1
  65.             teams.counter = line
  66.          end
  67.       end
  68.    end
  69.    close(datafile)
  70. end
  71. else do
  72.    say
  73.    say "ERROR :    (ViewTeamSchedule)"
  74.    say
  75.    say "Cannot open '"league_file||input_file"' for reading."
  76.    exit
  77. end
  78.  
  79. if autos = 0 then do
  80.    say
  81.    say "ERROR :    (ViewTeamSchedule)"
  82.    say
  83.    say "Cannot view schedules for '"search_team"'."
  84.    say
  85.    say "This program will only show schedule files that have"
  86.    say "created from a schedule definition file such as "
  87.    say "'Teams6.schd'. Program aborted."
  88.    say
  89.    exit
  90. end
  91.  
  92. sel=-1
  93. search_team = strip(search_team)
  94. do i=1 to counter
  95.    if pos(search_team,teams.i) > 0 then
  96.       sel = i
  97. end
  98. if sel > 0 then do
  99.    say
  100.    say center("Display Team Schedule in '"league_title"'",78)
  101.    say "-------------------------------------------------------------------------------"
  102.    say
  103.    say "Created from '"autofile"' schedule defintion file."
  104.    say
  105.    say
  106.    say "Games Played By: "teams.sel
  107.    say
  108.    say "Date/Week   Where?   Opponent"
  109.    say "----------------------------------------------------"
  110.    say
  111.    matches = 0
  112.    if open(datafile,league_file || input2_file,'r') then do
  113.       do while ~eof(datafile)
  114.          line = readln(datafile)
  115.          if pos(separator,line) > 0 then do
  116.             if pos("*Week:",line) > 0 then do
  117.                curr = subword(line,2)
  118.             end
  119.             if pos("*Date:",line) > 0 then do
  120.                year = word(line,5)
  121.                mnth = word(line,4)
  122.                day  = word(line,3)
  123.                curr = right(day,2,0)||" "||substr(mnth,1,3)||" "||substr(year,3,2)
  124.             end
  125.          end
  126.          if pos(separator,line) = 0 then do
  127.             if pos(not_played,line) > 0 then do
  128.                home_team = strip(substr(line,1,30))
  129.                away_team = strip(substr(line,41,30))
  130.  
  131.                strng = strip(teams.sel)
  132.                if strng = home_team then do
  133.                   say left(curr,12)"Home     "left(away_team,30)
  134.                   matches = matches + 1
  135.                end
  136.                if strng = away_team then do
  137.                   say left(curr,12)"Away     "left(home_team,30)
  138.                   matches = matches + 1
  139.                end
  140.             end
  141.          end
  142.       end
  143.       close(datafile)
  144.       say
  145.       if matches = 0 then
  146.          say "No matches to be played. The season is over..."
  147.       else
  148.          say "Number of matches to be played:  "matches
  149.       say
  150.       say "-------------------------------------------------------------------------------"
  151.       say
  152.    end
  153.    else do
  154.       say
  155.       say "ERROR :    (ViewTeamSchedule)"
  156.       say
  157.       say "Cannot read '"league_file || input2_file"' datafile."
  158.       exit
  159.    end
  160. end
  161. else do
  162.    say
  163.    say "ERROR :    (ViewTeamProgress)"
  164.    say
  165.    say "Incorrect team. '"search_team"' cannot be found in this"
  166.    say "league."
  167. end
  168.  
  169. exit